// ==UserScript==
// @name           Gmail Air Plus
// @description    Gmail Air Skin Revolution (with options)
// @namespace      amio.cn
// @author         amio
// @date           2009-04-08
// @include        https://mail.google.com/*
// @include        http://mail.google.com/*
// ==/UserScript==

var aGapColors = new Array();
// cssNavBorderColor, cssThreadBackHL;
aGapColors[0] = ["#C3D9FF","#E1ECFF"];			// aGapColors[0000] for theme: Default

var gapTS = 0; // gapThemeSelected
if (!GM_getValue("gapThemeSelected")){
	GM_setValue("gapThemeSelected",0);
}else{
	gapTS = GM_getValue("gapThemeSelected");
}

// default color
var cssNavBorderColor = aGapColors[gapTS][0];
var cssThreadBackHL = aGapColors[gapTS][1];

(function() {

	var cssGlobal =
			//win,mac,linux
			"body.cP, #ContactManager * { font-family: verdana, geneva, kalimati, sans-serif !important }" +
			//Side Column & All Nav Button & Settings content & button
			".pp *, .pX *, .v *, .goog-imageless-button-content { font-family: verdana, geneva, kalimati, sans-serif !important }" +
			//Setting page LANUGAGE SELECT height fix
			".v9 select { height: 23px !important }" +
			//input or textarea border
			".nr { border-color: #AAA !important }" +
			".nr:focus { border-color: #73A6FF !important }" +
			//Footer
			"div.l2 { font-family: verdana, geneva, kalimati, sans-serif !important }" +
			"div.mn { display: none !important }";

	var cssSideColumn =
			// Nav link button style ( all )
			".qk * { line-height: 22px !important }" +
			".pX a, .pX span.p9 { display: block !important }" +
			".pX img { position: absolute !important; top: 5px !important; right: 7px !important }" +
			".pk img { position: absolute !important; top: 6px !important; right: 6px !important }" +
			".pX .k { margin: 0 !important }" +
			// Gmail rounded corner, disable them for unCurrent NavLink
			".pX div.pi { display: none !important }" +
			// Nav link button [var:cssNavBorderColor]
			".pX a, .pX span.p9 {" +
				"-moz-border-radius: 5px 0 0 5px !important;" +
				"border: 1px solid " + cssNavBorderColor + " !important;" +
				"cursor: pointer !important;" +
				"text-decoration: none !important;" +
				"padding-left: 8px !important }" +
			".pX a:hover, .pX span.p9:hover { background-color: " + cssNavBorderColor + " !important }" +
			".pX { margin: 0 3px 3px 0 !important }" +
			".pk { margin: 0 0 3px 0 !important }" +
			// CURRENT Nav Link Button
			".pk * { font-size: 14px !important; line-height: 25px !important; font-weight: bold !important; text-decoration: none !important }" +
			// ComposeMail & Contacts Button ( .pz  or .pA ? )
			".pz { font-family: verdana !important; }" +
			// Spam & Trash
			".pX a.qh { border-color: #CCC !important; color: gray !important }" +
			".pX a.qh:hover { background-color: #CCC !important }" +
			// remove invite box
			"div.pY { display: none !important }";

	var cssRemoveChatbox = "div.s { display: none !important }";

	var cssThreadList =
			// List Header & Footer
			".D * { font-family: verdana, geneva, kalimati, sans-serif !important }" +
			// text link highlight
			".D span[role=\"link\"]:hover, .AP:hover { color: red !important; text-decoration: underline !important }" +
			// Thread LIST
			"div.VOR3D * { font-family: verdana, geneva, kalimati, sans-serif !important }" +
			// All Conversation Item
			"tr.zA>td { padding: 0 5px 0 1px !important; line-height: 24px !important }" +
			"tr.zA>td>div { height: 24px !important }" +
			// blank thread tr
			"tr.zs { height: 25px !important }" +
			// unread
			"tr.zE:hover { background-color: #E1ECFF !important; background-image: none !important }" +
			// read
			"tr.yO:hover { background-color: #D4E4FF !important; background-image: none !important }" +
			// checked
			"tr.x7 { background-color: #FFC !important; }" +
			"tr.x7:hover { background-color: #FFE699 !important; background-image: none !important }" +
			// smaller right side date td
			"col.xX { width: 75px !important; padding-left: 0 !important }" +
			// label [ar,as > at > au > av]
			"div.ar { padding-top: 3px !important; height: 20px !important }" +
			"div.au { padding: 1px !important }" +
			"div.av { padding: 0 2px !important; font-size: 12px !important; line-height: 14px !important }";

	var cssConversation =
			// remove ads
			".u5, .u8 { display: none !important }" +
			// Quick Link button ( Print All, New Window, etc ) position
			"table.iY > tr > td:first-child + td > div { width: auto !important }" +
			"table.iY > tr > td:first-child + td + td > div { width: 0 !important; position: relative !important }" +
			"table.iY > tr > td:first-child + td + td > div > div { position: absolute !important; right: 0 !important; top: 0 !important }" +
			// Quick Link button ( Print All, New Window, etc ) style
			"table.iY div.hj { width: auto !important; font-family: verdana, geneva, kalimati, sans-serif !important }" +
			"table.iY div.hj div.hk { display: inline !important; padding-right: 10px !important }" +
			"table.iY div.hj div.hk span img { display: none !important }" +
			"table.iY div.hj div.hk span {" +
				"padding: 0px 6px 1px 6px !important;" +
				"border: 1px solid " + cssNavBorderColor + " !important;" +
				"border-top-width: 0 !important;" +
				"-moz-border-radius: 0 0 4px 4px !important }" +
			"table.iY div.hj div.hk span u { text-decoration: none !important }" +
			"table.iY div.hj div.hk span:hover { background-color: " + cssNavBorderColor + " !important }" +
			// Mail Title and Labels
			"div.if h1.ha { font-size: 20px !important; line-height: 26px !important; font-family: Georgia, serif !important; margin-top: 20px !important; position: relative !important }" +
			"div.if h1.ha span.hP { padding: 0 !important }" +
			"div.if h1.ha span:first-child + span { position: absolute !important; top: -20px !important; left: 3px !important }" +
			"div.if h1.ha table * { font-size: 12px !important; line-height: 14px !important }" +
			// Reply Box resize
			"div[class=\"ip iq\"] { margin-right: 13px !important }" +
			"textarea.ir { width: 100% !important }" +
			// "show details" fix (blue frame right-side)
			"table[class='T1HY1 nH iY'] { width: 100% !important }" +
			// font family
			".gE *," +
			".gB div, .gB span { font-family: verdana, geneva, kalimati, sans-serif !important }";

	var cssElse =
			".goog-menuitem * { white-space: nowrap !important }" +
			".goog-tristatemenuitem-highlight, .goog-menuitem-highlight { background-color: #E0ECFF !important }" +
			".goog-imageless-button-outer-box .goog-imageless-button-content { font-size: 12px !important; line-height: 20px !important }" +
			// gapButton Style
			"#gapOption { padding-left: 4px }" +
			"#gapButton { text-decoration: none; outline: none }" +
			"#gapDialog { background-color: #FFF; border: 1px solid red; padding: 10px }";

	// ================================ Build All CSS ================================
	var gapCSS = cssGlobal + cssSideColumn + cssThreadList + cssConversation + cssElse;

	// ================================  Insert  CSS  ================================
	if (typeof GM_addStyle != "undefined") {
		GM_addStyle(gapCSS);
	} else if (typeof addStyle != "undefined") {
		addStyle(gapCSS);
	} else {
		var heads = document.getElementsByTagName("head");
		if (heads.length > 0) {
			var node = document.createElement("style");
			node.type = "text/css";
			node.appendChild(document.createTextNode(gapCSS));
			heads[0].appendChild(node);
		}
	}
})();

// ================================  Insert (gap) Button  ================================

(function() {
	var gapOptionSet = document.createElement("span");
	gapOptionSet.setAttribute("id","gapOption");
	gapOptionSet.style.position = "relative";
	gapOptionSet.innerHTML = '<a id="gapButton" class="e" href="#" onclick="document.getElementById(\'gapDialog\').style.display=\'block\';">(gap)</a>' +
			'<div id="gapDialog" style="display:none; position:absolute; right:0">adsfasdf</div>';

	function setGAP(){
		if (document.getElementById("guser")) {
			document.getElementById("guser").firstChild.firstChild.appendChild(gapOptionSet);
			window.clearInterval(intervalID);
		}
	}

	var intervalID = window.setInterval(setGAP, 500);

})();
 